﻿
@using System.Data
@using GatewayServer.Common;


@using UtilsBase;
@{
    ViewBag.PageTitle = "设备数据";

    Layout = "~/Views/Shared/PageTemplate.cshtml";
}

<script>
    $(document).ready(function () {
        if ($("#p_guid").val() == "") {
            document.getElementById("butbackproduct").style.display = "none";
        }
    });
    function changeStatus(dguid) {
        $.post("changeStatus", { "flag": Math.random(), guid: dguid }, function (result) {
            var jsonresult = (result);
            if (jsonresult.respCode == "200") {
                window.location.reload();
            }
            else {
                alert(jsonresult.respMsg);
                return;
            }
        });
    }
</script>
<style>
    td {
        min-width: 100px;
    }

    div {
        font-family: "微软雅黑"
    }

    .device_nickname {
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        color: #7d71ee;
    }
</style>
<meta http-equiv="refresh" content="3">
<div id="saper-container">
    <form id="searchForm" name="searchForm" action="list" method="post">
        <input type="hidden" name="p_guid" id="p_guid" value="@(Context.Request.Query["p_guid"])" />
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>设备数据</h2>
            </div>
            <div class="subfiled-content">
              @*  <div class="search-box clearfix">

                  
                    <a href="javascript:window.location.href ='/product/list';" id="butbackproduct" name="butbackproduct" class="sapar-btn sapar-btn-recom query-btn">返回</a>
                </div>*@
                <!--表格开始-->
                <div >

                    <div style="clear:both"></div>
            <div class="kv-item clearfix" style="font-size:16px;font-weight:bold;margin-top:10px;">网关</div>
            <hr />
            @foreach (DataRow dr in ((DataTable)ViewData["geteway_vd"]).Rows)
            {
                string color = "";
                if (dr["onlinestate"].ToString().Contains("在线"))
                {
                    color = "background-color:#bae9f2;";
                }
                else
                {
                    color = "background-color: #e8eed6;";
                }
                <div style="border: 1px solid gainsboro; min-width: 90px; height: 70px; margin: 5px; border-radius: 10px;@color float: left; cursor: pointer; padding: 10px;" onclick="javascript:window.location.href='../Mager_IOT_Device_Gateway_Set/list?guid=@dr["gw_guid"]'">
                    <div class="device_nickname">@dr["d_name"]</div>
                    <div style="text-align: center; font-size: 12px; color: gray; ">@dr["onlinestate"]</div>
                    <div style="text-align:center;font-size:12px;color:#c1b9b9">@dr["ip"]</div>
                    <div style="height:15px;text-align: center;font-size:8px; color:#c1b9b9 ">编码:@dr["d_code"]</div>
                </div>
            }

             <div style="clear:both"></div>
                    <div style="clear:both"></div>
                    <div class="kv-item clearfix" style="font-size:16px;font-weight:bold;margin-top:10px;">设备</div>
                    <hr />
                    @foreach (DataRow drdevice in ((DataTable)ViewData["dtDevice"]).Rows)
                    {
                        <div style="border: 1px solid gainsboro;  height: 95px; margin: 5px; border-radius: 10px; background-color: #e8eed6; float: left; cursor: pointer; padding: 10px;min-width:150px">

                            <div class="device_nickname">@drdevice["d_name"]</div>
                            <div style="text-align:center;font-size:12px;color:gray">@drdevice["state"]
                                @if (drdevice["ls_live_state"].ToString() == "2")
                                {
                                    <font>-无响应</font>
                                }
                            </div>
                            <div style="height:15px;text-align: center;font-size:8px; color:#c1b9b9 ">编码:@drdevice["gatewaycode"]-@drdevice["d_code"]</div>
                            <div style="">
                            @foreach (DataRow drvalue in ((DataTable)ViewData["dtvalue"]).Select(" vc_d_guid='" + drdevice["d_guid"] + "'"))
                            {
                                    <div style="float:left;margin:5px;">
                                    <div style="text-align:center;font-size:12px;color:#6592d9">@drvalue["vc_name"]</div>
                                    <div style="text-align:center;font-size:14px;color:#6592d9">@drvalue["vc_value"]@drvalue["v_unit"]</div>
                                </div>
                            }
                          
                            <div style="clear:both"></div>
                            </div>
                        </div>
                    }


                </div><!--表格结束-->
            </div>
        </div>
        <div id="saper-ft"></div>
    </form>
</div>
